aboutsummaryrefslogtreecommitdiff
path: root/src/routes/tools/[tool]/+page.svelte
blob: 63596844a45f857985353083de3276c249da1e20 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<script lang="ts">
	import Hayai from './../../../lib/Tools/Hayai.svelte';
	import UmaMusumeBirthdays from './../../../lib/Tools/UmaMusumeBirthdays.svelte';
	import ActivityHistory from '$lib/Tools/ActivityHistory/Tool.svelte';
	import Wrapped from '$lib/Tools/Wrapped/Tool.svelte';
	import EpisodeDiscussionCollector from '$lib/Tools/EpisodeDiscussionCollector.svelte';
	import CharacterBirthdays from '$lib/Tools/Birthdays.svelte';
	import SequelSpy from '$lib/Tools/SequelSpy.svelte';
	import { closest } from '$lib/Error/path';
	import HeadTitle from '$lib/Home/HeadTitle.svelte';
	import RandomFollower from '$lib/Tools/RandomFollower.svelte';
	import DumpProfile from '$lib/Tools/DumpProfile.svelte';
	import { tools } from '$lib/Tools/tools.js';
	import { onMount } from 'svelte';
	import { goto } from '$app/navigation';
	import Picker from '$lib/Tools/Picker.svelte';
	import Likes from '$lib/Tools/Likes.svelte';
	import root from '$lib/Utility/root.js';
	import Popup from '$lib/Layout/Popup.svelte';
	import HololiveBirthdays from '$lib/Tools/HololiveBirthdays.svelte';

	export let data;

	let tool = data.tool ?? 'default';

	onMount(() => {
		if (tool === 'default') goto(root('/tools'));
	});

	$: suggestion = closest(tool, Object.keys(tools));

	$: if (tool == 'girls') goto(root('/girls'));
</script>

<Picker bind:tool />

{#if !Object.keys(tools).includes(tool)}
	<HeadTitle route="Tools" path="/tools" />

	<Popup>
		<p style="text-align: center;">
			Tool "<a href={root(`/tools/${tool}`)}>{tool}</a>" not found
		</p>

		<blockquote style="margin: 0 0 0 1.5rem;">
			Did you mean "<a
				href={root(`/tools/${tools[suggestion].id}`)}
				on:click={() => (tool = suggestion)}
				style={suggestion === '...' ? 'pointer-events: none; color: inherit;' : ''}
			>
				{suggestion === '...' ? '...' : tools[suggestion].name()}</a
			>"?
		</blockquote>
	</Popup>
{:else}
	<HeadTitle route={tools[tool].name()} path={`/tools?tool=${tool}`} />

	{#if tool === 'activity_history'}
		<ActivityHistory user={data.user} />
	{:else if tool === 'wrapped'}
		<Wrapped user={data.user} />
	{:else if tool === 'discussions'}
		<EpisodeDiscussionCollector />
	{:else if tool === 'birthdays'}
		<CharacterBirthdays />
	{:else if tool === 'sequel_spy'}
		<SequelSpy user={data.user} />
	{:else if tool === 'random_follower'}
		<RandomFollower />
	{:else if tool === 'dump_profile'}
		<DumpProfile />
	{:else if tool === 'likes'}
		<Likes />
	{:else if tool === 'uma_musume_birthdays'}
		<UmaMusumeBirthdays />
	{:else if tool === 'hayai'}
		<Hayai />
	{:else if tool === 'hololive_birthdays'}
		<HololiveBirthdays />
	{/if}
{/if}